package com.hc.javabasestudyproject.juc.cas;

import javafx.util.Pair;
import lombok.SneakyThrows;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @Author: huangcheng
 * @CreateTime: 2024-04-11  10:03
 * @Description:
 * @Version: 1.0
 */
public class CASTest {
    @SneakyThrows
    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(0);
        for (int i = 0; i < 100; i++) {
            new Thread(()->{
                atomicInteger.incrementAndGet();
            }).start();
        }
        Thread.sleep(1000);
        atomicInteger.compareAndSet(100,20);
        System.out.println(atomicInteger.get());
    }
}
